Conversation
|
The following pipelines have been queued for testing: |
| # Renders chart templates locally without deployment | ||
| [Parameter(Mandatory=$False)][switch]$Template, | ||
|
|
||
| [Parameter(Mandatory=$False)][switch]$RerunFailedJobs, |
There was a problem hiding this comment.
I know all the wording in the original issue says "Rerun" but I'm thinking "Retry" is a better choice here?
There was a problem hiding this comment.
Also it would be retrying failed pods, not jobs. Should we call it something like RetryFailedTests?
| $pods = kubectl get pods -n $pkg.namespace -o json | ConvertFrom-Json | ||
|
|
||
| # Get all jobs within this helm release | ||
| $helmResources = helm status -n $pkg.Namespace $pkg.ReleaseName --show-resources |
There was a problem hiding this comment.
A comment here with an example of the output would be nice.
| foreach ($helmResource in $helmResources) { | ||
| if ($discoveredJob -and $helmResource -match "==>") {break} | ||
| if ($discoveredJob) { | ||
| $jobs += ($helmResource -split '\s+')[0] | where{($_ -ne "NAME") -and ($_)} |
There was a problem hiding this comment.
| $jobs += ($helmResource -split '\s+')[0] | where{($_ -ne "NAME") -and ($_)} | |
| $jobs += ($helmResource -split '\s+')[0] | Where-Object {($_ -ne "NAME") -and ($_)} |
There was a problem hiding this comment.
what's the advantage of doing so?
There was a problem hiding this comment.
"where" seems to only work on arrays & will return empty array instead of null when no matches were found
There was a problem hiding this comment.
We favor using full cmdlet names to reduce confusion (see explanation). For example, where as it is used here is an alias for Where-Object and is specifically different from .Where() which I think you are describing?
| # Included packages: https://github.com/microsoft/CBL-Mariner/blob/1.0/SPECS/core-packages/core-packages.spec | ||
|
|
||
| ADD ./poll.sh /poll.sh | ||
| RUN tdnf -y install wget |
| } | ||
|
|
||
| if (!$genValRerun.scenarios.length) { | ||
| Write-Host "There are no failed jobs to rerun." |
| $genVal = Get-Content $genValFile -Raw | ConvertFrom-Yaml -Ordered | ||
| $releaseName = $pkg.ReleaseName | ||
| if ($RerunFailedJobs) { | ||
| $pods = kubectl get pods -n $pkg.namespace -o json | ConvertFrom-Json |
There was a problem hiding this comment.
Can we move this into its own helper function? That will make the outer function smaller and it will be easier to tell which variables are set/updated from this scope that are important for the remaining function code.
|
The following pipelines have been queued for testing: |
| $genVal = Get-Content $genValFile -Raw | ConvertFrom-Yaml -Ordered | ||
| $releaseName = $pkg.ReleaseName | ||
| if ($RetryFailedTests) { | ||
| runRetryTests $pkg ([ref]$releaseName) ([ref]$genVal) |
There was a problem hiding this comment.
Let's just return new values instead of using refs here, to reduce future bug possibilities and make the code clearer.
| runRetryTests $pkg ([ref]$releaseName) ([ref]$genVal) | |
| $releaseName, $genVal = runRetryTests $pkg $releaseName $genVal |
Also the naming here is still confusing. runRetryTests doesn't actually run anything, it just generates the new $genVal value. $genVal is also still a non-obvious name for this variable, maybe something more along these lines:
$genValFile -> $generatedHelmValuesFilePath
$genVal -> $generatedHelmValues
| $pods = kubectl get pods -n $pkg.namespace -o json | ConvertFrom-Json | ||
|
|
||
| # Get all jobs within this helm release | ||
| $helmResources = helm status -n $pkg.Namespace $pkg.ReleaseName --show-resources |
There was a problem hiding this comment.
| $helmResources = helm status -n $pkg.Namespace $pkg.ReleaseName --show-resources | |
| $helmResources = RunOrExitOnFailure helm status -n $pkg.Namespace $pkg.ReleaseName --show-resources |
| foreach ($helmResource in $helmResources) { | ||
| if ($discoveredJob -and $helmResource -match "==>") {break} | ||
| if ($discoveredJob) { | ||
| $jobs += ($helmResource -split '\s+')[0] | Where-Object {($_ -ne "NAME") -and ($_)} | ||
| } | ||
| if ($helmResource -match "==> v1/Job") { | ||
| $discoveredJob = $True | ||
| } | ||
| } |
There was a problem hiding this comment.
Another suggestion for clearer variable names:
| foreach ($helmResource in $helmResources) { | |
| if ($discoveredJob -and $helmResource -match "==>") {break} | |
| if ($discoveredJob) { | |
| $jobs += ($helmResource -split '\s+')[0] | Where-Object {($_ -ne "NAME") -and ($_)} | |
| } | |
| if ($helmResource -match "==> v1/Job") { | |
| $discoveredJob = $True | |
| } | |
| } | |
| foreach ($line in $helmStatusOutput) { | |
| if ($discoveredJob -and $line -match "==>") {break} | |
| if ($discoveredJob) { | |
| $jobs += ($line -split '\s+')[0] | Where-Object {($_ -ne "NAME") -and ($_)} | |
| } | |
| if ($line -match "==> v1/Job") { | |
| $discoveredJob = $True | |
| } | |
| } |
| $revision = $jobRevision | ||
| } | ||
|
|
||
| $podPhase = kubectl describe jobs -n $pkg.Namespace $job | Select-String "0 Failed" |
There was a problem hiding this comment.
| $podPhase = kubectl describe jobs -n $pkg.Namespace $job | Select-String "0 Failed" | |
| $jobOutput = RunOrExitOnFailure kubectl describe jobs -n $pkg.Namespace $job | |
| $podPhase = $jobOutput | Select-String "0 Failed" |
| } | ||
|
|
||
| function runRetryTests ($pkg, [ref]$releaseName, [ref]$genVal) { | ||
| $pods = kubectl get pods -n $pkg.namespace -o json | ConvertFrom-Json |
There was a problem hiding this comment.
| $pods = kubectl get pods -n $pkg.namespace -o json | ConvertFrom-Json | |
| $podOutput = RunOrExitOnFailure kubectl get pods -n $pkg.namespace -o json | |
| $pods = $podOutput | ConvertFrom-Json |
|
Just some exit handling and naming comments otherwise this is looking good. I think because the variables are untyped and getting used across so much code we need to be extra careful that the variable names describe their underlying values accurately. |
| @@ -0,0 +1,16 @@ | |||
|
|
|||
| function determineRetryTests ([ref] $val, [ref]$val2) { | |||
There was a problem hiding this comment.
Did you mean to check this in? If so let's make it a pester test: https://github.com/Azure/azure-sdk-tools/blob/main/doc/development/powershell.md#unit-testing
There was a problem hiding this comment.
oh no, accident, it's my testing ps script
|
The following pipelines have been queued for testing: |
|
The following pipelines have been queued for testing: |
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#5726 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow) --------- Co-authored-by: Albert Cheng <albertcheng@microsoft.com>
|
Hello @azure-sdk! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
closes #5361